package com.yuyu.tt.context;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 深海鱼鱼
 * @version 1.0
 * @description:
 * @date 2024/11/20 14:49
 */
@Slf4j
public class TenantContextHolder {

    /**
     * 多租户-项目code
     */
    public static final ThreadLocal<String> PROJECT_CODE_LOCAL = new ThreadLocal<>();

    /**
     * 获取多租户-项目code
     *
     * @param
     * @return java.lang.String
     */
    public static String getProjectCode() {
        return PROJECT_CODE_LOCAL.get();
    }

    /**
     * 设置多租户-项目code
     *
     * @param projectCode
     * @return void
     */
    public static void setProjectCode(String projectCode) {
        PROJECT_CODE_LOCAL.set(projectCode);
        log.info("租户设置完成，当前projectCode: [{}]", PROJECT_CODE_LOCAL.get());
    }

    /**
     * 删除多租户-项目code
     *
     * @param
     * @return void
     */
    public static void removeProjectCode() {
        PROJECT_CODE_LOCAL.remove();
        log.info("租户缓存清理完成...");
    }

}
